const Database = require('better-sqlite3');
const path = require('path');

const DB_PATH = path.join(process.cwd(), 'data', 'delivery-management.db');
const db = new Database(DB_PATH);

console.log('📋 检查parameter_field_metadata表结构');
console.log('=====================================');

try {
  const tableInfo = db.prepare("PRAGMA table_info(parameter_field_metadata)").all();
  console.log('\n📊 parameter_field_metadata表结构:');
  tableInfo.forEach(col => {
    console.log(`  ${col.cid}. ${col.name} (${col.type})`);
  });
  
  // 检查现有的table_c14相关数据
  console.log('\n📋 现有table_c14字段元数据:');
  const existingMetadata = db.prepare("SELECT * FROM parameter_field_metadata WHERE table_name = 'table_c14'").all();
  existingMetadata.forEach(field => {
    console.log(`  ${field.sequence_number || 'N/A'}. ${field.field_name} (${field.data_type}) [${field.data_source}]`);
  });
  
} catch (error) {
  console.error('❌ 错误:', error.message);
} finally {
  db.close();
}